
// 字典常量的定义

var categoryList = [
  { value: 0, label: '智能家居' },
  { value: 1, label: '车联网' },
  { value: 2, label: '环境监控' },
  { value: 3, label: '可穿戴设备' },
  { value: 4, label: '工业采集' },
  { value: 5, label: '新能源' },
  { value: 6, label: '其他' }
]

var protocolList = [
  { value: 0, label: 'MQTT' }
]

var joinTypeList = [
  { value: 0, label: 'WIFI' },
  { value: 1, label: '2G' },
  { value: 2, label: '3G' }
]

var streamType = [
  { value: 0, label: '数值型' },
  { value: 1, label: '开关型' },
  { value: 2, label: 'GPS型' }
]

var ruleType = [
  { value: 1, label: '>' },
  { value: 2, label: '>=' },
  { value: 3, label: '<' },
  { value: 4, label: '<=' },
  { value: 5, label: '=' }
]

var actionType = [
  { value: 1, label: '邮件' },
  { value: 2, label: '短信' },
  { value: 3, label: '邮件和短信' }
]

export function transCategory (idx) {
  if (idx !== null) {
    for (var j = 0, len = categoryList.length; j < len; j++) {
      if (categoryList[j].value === idx) {
        return categoryList[j].label
      }
    }
  }
  return '无效的分类'
}

export function transProtocol (idx) {
  if (idx !== null) {
    for (var j = 0, len = protocolList.length; j < len; j++) {
      if (protocolList[j].value === idx) {
        return protocolList[j].label
      }
    }
  }
  return '无效的分类'
}

export function transJoinType (idx) {
  if (idx !== null) {
    for (var j = 0, len = joinTypeList.length; j < len; j++) {
      if (joinTypeList[j].value === idx) {
        return joinTypeList[j].label
      }
    }
  }
  return '无效的分类'
}

export function transStreamType (idx) {
  if (idx !== null) {
    for (var j = 0, len = streamType.length; j < len; j++) {
      if (streamType[j].value === idx) {
        return streamType[j].label
      }
    }
  }
  return '无效的分类'
}

export function transRuleType (idx) {
  if (idx !== null) {
    for (var j = 0, len = ruleType.length; j < len; j++) {
      if (ruleType[j].value === idx) {
        return ruleType[j].label
      }
    }
  }
  return '无效的分类'
}

export function transActionType (idx) {
  if (idx !== null) {
    for (var j = 0, len = actionType.length; j < len; j++) {
      if (actionType[j].value === idx) {
        return actionType[j].label
      }
    }
  }
  return '无效的分类'
}

export default { categoryList, protocolList, joinTypeList, streamType, ruleType, actionType }
